package com.ijunfu.detail.thread._01_Thread;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.TimeUnit;

/**
 *
 * @Title  : 
 * @Author : ijunfu <ijunfu@163.com>
 * @Date   : 2023/11/23 16:39
 * @Version: 1.0
 * @Motto  : 世界很大 世界很小
 *
 */
@Slf4j
public class _15Main {

    public static void main(String[] args) {

        Thread t1 = new Thread(()->{
            while (true) {
                try {
                    TimeUnit.SECONDS.sleep(2L);
                } catch (InterruptedException e) {
                    Thread.currentThread().interrupt();
                }

                log.info("监控中...");
            }
        });

        // 设置t1线程为守护线程，当主线程退出时，t1线程也会退出
        t1.setDaemon(Boolean.TRUE);

        // 启动线程
        t1.start();

        log.info("finish");
    }
}
